import java.io.IOException;

import org.apache.commons.net.telnet.TelnetClient;

public class TelnetWrite{
	private TelnetClient tc;
	
	public TelnetWrite(TelnetClient tc){
		this.tc = tc;
	}
	
	public void sendPing() throws IOException{
		sendMessage("P");
	}
	
	public void sendMove(int direction) throws IOException{
		sendMessage(Integer.toString(direction));
	}
	
	public void sendMessage(String message) throws IOException{
		byte[] buff = new byte[1024];
		for(int i=0;i<message.length();i++){
			buff[i] = (byte)message.charAt(i);
		}
		tc.getOutputStream().write(buff,0,message.length());
		tc.getOutputStream().flush();
	}
}